package edu.cicese.tm;

import com.jsurf.InterestPoint;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 24/06/11
 * Time: 02:31 PM
 */
public class ImageClusters implements Serializable{
	private static final long serialVersionUID = 1;

	public String id;
	public Map<InterestPoint, ArrayList<Match>> clusters;

	public ImageClusters(String id) {
		this.id = id;
		clusters = new HashMap<InterestPoint, ArrayList<Match>>();
	}

	public void add(Map<InterestPoint, InterestPoint> matchedPoint, String matchID) {
		for (Entry<InterestPoint, InterestPoint> entry : matchedPoint.entrySet()) {
			if (clusters.containsKey(entry.getValue())) {
				clusters.get(entry.getValue()).add(new Match(matchID, entry.getKey()));
			}
//			else {
//				ArrayList<Match> matches = new ArrayList<Match>();
//				matches.add(new Match(matchID, entry.getKey()));
//				clusters.put(entry.getValue(), matches);
//			}
		}
	}

	public void create(List<InterestPoint> points) {
		for (InterestPoint ip : points) {
			clusters.put(ip, new ArrayList<Match>());
		}
	}
}
